<?php
include("include/session.php");
?>

<html>
<body>

<?php
/* Sprawdzanie czy user*/
$req_user = trim($_GET['user']);
if(!$req_user || strlen($req_user) == 0 ||
   !eregi("^([0-9a-z])+$", $req_user) ||
   !$database->usernameTaken($req_user)){
   die("Uzytkownik niezarejestrowany");
}

/* Logged in user viewing own account */
if(strcmp($session->username,$req_user) == 0){
   echo "<h1>Moje konto</h1>";
}
/* Visitor not viewing own account */
else{
   echo "<h1>User Info</h1>";
}

/* Display requested user information */
$req_user_info = $database->getUserInfo($req_user);

/* Username */
echo "<b>Uzytkownik: ".$req_user_info['username']."</b><br>";

/* Email */
echo "<b>Email:</b> ".$req_user_info['email']."<br>";


if(strcmp($session->username,$req_user) == 0){
   echo "<br><a href=\"useredit.php\">Edytuj konto</a><br>";
}


echo "<br>Wroc do [<a href=\"main.php\">Strony glownej</a>]<br>";

?>

</body>
</html>
